//
//  OnlinePhoneNumSearcher.m
//  PhoneBook
//
//  Created by valkyrie on 8/19/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "OnlinePhoneNumSearcher.h"


@implementation OnlinePhoneNumSearcher


- (id) init {
	[super init];
	
	return self;
}

- (void) testSearch {

}

- (void) queryForArrayAsyn:(id) query delegate:(id) caller {
	
	NSString * encodedQueryStr = (NSString *)CFURLCreateStringByAddingPercentEscapes(
								   NULL,
								   (CFStringRef)query,
								   NULL,
								   (CFStringRef)@"!*'();:@&=+$,/?%#[]",
								   kCFStringEncodingUTF8 );	
	
	NSString *queryParams = [NSString stringWithFormat:@"?query=%@", encodedQueryStr];
	
	
	NSString *queryapiStr = [NSString stringWithFormat:@"http://phonebook.yahoo.co.jp/search/%@", queryParams];
	
	NSLog(@"query url [%@]", queryapiStr);
	
	NSURL* url = [NSURL URLWithString:queryapiStr];
	
	NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
	[request setHTTPMethod:@"GET"];
	
	NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:caller];

	[caller setConn:connection];
	
}



- (void) dealloc {

	[super dealloc];
}

@end
